﻿/**********************************************************************
 * @file   GUILoadCaseDialog.h
 * @brief  载荷工况窗口声明
 * @author liuzhonghua (liuzhonghuaszch@163.com)
 * @date   2025-02-24
 *********************************************************************/
#ifndef _GUILoadCaseDialog_H
#define _GUILoadCaseDialog_H

#include "GUIPostDialogAPI.h"
#include "GUIWidget/GUIDialogBase.h"
#include <QTreeWidget>
#include <QStack>

namespace Ui {
    class GUILoadCaseDialog;
}

namespace Core
{
    class FITKActionOperator;
}

namespace Acoustics 
{
    class FITKAcousticsSolverLoadCase;
}

namespace GUI
{
    /**
     * @brief  载荷工况窗口
     * @author liuzhonghua (liuzhonghuaszch@163.com)
     * @date   2024-2-12
     */
    class GUIPostDialogAPI GUILoadCaseDialog :public GUIDialogBase
    {
        Q_OBJECT;
    public:
        /**
         * @brief    构造函数（创建数据）
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        GUILoadCaseDialog(Core::FITKActionOperator* oper, QWidget* parent = nullptr);
        /**
         * @brief    构造函数（修改数据）
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-19
         */
        GUILoadCaseDialog(int groupObjID, Core::FITKActionOperator* oper, QWidget* parent = nullptr);
        /**
         * @brief    析构函数
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        virtual ~GUILoadCaseDialog();
 
    private slots:
        /**
         * @brief    添加按钮点击事件
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        void on_pushButton_Add_clicked();
        /**
         * @brief    移除按钮点击事件
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        void on_pushButton_Remove_clicked();
        /**
         * @brief    确定按钮点击事件
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        void on_pushButton_OK_clicked();
        /**
         * @brief    关闭按钮点击事件
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        void on_pushButton_Cancel_clicked();

    private:
        /**
         * @brief    初始化数据
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        void init();
        /**
         * @brief    初始化图标
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        void initImage();
        /**
         * @brief    初始化树
         * @param[i] rootItem 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        void initLoadTree(QTreeWidgetItem* rootItem);
        /**
         * @brief    初始化表格
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        void initLoadTable();
        /**
         * @brief    获取树节点
         * @param[i] item 
         * @param[i] objID 
         * @return   QTreeWidgetItem *
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        QTreeWidgetItem* findTreeWidgetItemRecursive(QTreeWidgetItem *item, int objID);
        /**
         * @brief    设置载荷树节点
         * @param[i] geometryItem 
         * @param[i] type 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        void setLoadTreeItems(QTreeWidgetItem *geometryItem, int type);
        /**
         * @brief    创建数据
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        bool createObjData();
        /**
         * @brief    修改数据
         * @return   bool
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        bool editObjData();
        /**
         * @brief    从窗口获取数据
         * @param[i] loadCase 
         * @return   void
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2025-02-24
         */
        void getDataFormWidget(Acoustics::FITKAcousticsSolverLoadCase* loadCase);

    private:
        /**
         * @brief    ui
         * @author   liuzhonghua (liuzhonghuaszch@163.com)
         * @date     2024-2-12
         */
        Ui::GUILoadCaseDialog* _ui = nullptr;
        /**
         * @brief  操作器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-24
         */
        Core::FITKActionOperator* _oper = nullptr;
        /**
         * @brief  载荷工况数据ID
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-19
         */
        int _loadCaseObjID = -1;
        /**
         * @brief  是否创建载荷工况
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date   2025-02-24
         */
        bool _isCreate{ false };
    };
}
#endif
